{% extends "submit/submit_base.html" %}
{# Copyright The IETF Trust 2015, All Rights Reserved #}
{% load origin %}
{% load static %}
{% load django_bootstrap5 %}
{% load submit_tags %}
{% load misc_filters %}
{% block pagehead %}
    {{ block.super }}
    {{ all_forms|merge_media:'css' }}
{% endblock %}
{% block title %}Adjust meta-data of submitted {{ submission.name }}{% endblock %}
{% block submit_content %}
    {% origin %}
    <div class="modal fade"
         id="twopages"
         tabindex="-1"
         role="dialog"
         aria-labelledby="twopageslabel"
         aria-hidden="true">
        <div class="modal-dialog modal-dialog-scrollable modal-xl">
            <div class="modal-content">
                <div class="modal-header">
                    <p class="h5 modal-title" id="twopageslabel">First two pages of {{ submission.name }}-{{ submission.rev }}</p>
                    <button type="button"
                            class="btn-close"
                            data-bs-dismiss="modal"
                            aria-label="Close"></button>
                </div>
                <div class="modal-body">{{ submission|two_pages_decorated_with_errors:errors }}</div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
                </div>
            </div>
        </div>
    </div>
    <h2 class="mt-5">Adjust meta-data of submitted {{ submission.name }}</h2>
    <table class="table table-sm table-striped">
        <tbody>
        <tr>
            <th scope="row">Document</th>
            <td>
                {{ submission.name }}
                <button class="btn btn-primary btn-sm float-end ms-1"
                        type="button"
                        data-bs-toggle="modal"
                        data-bs-target="#twopages">
                    View first two pages
                </button>
                {% show_submission_files submission %}
            </td>
        </tr>
        <tr>
            <th scope="row">Submission date</th>
            <td>{{ submission.submission_date }}</td>
        </tr>
        <tr>
            <th scope="row">Group</th>
            <td>
                {{ submission.group|default:"Individual Submission" }}
                {% if submission.group %}<a href="{{ submission.group.about_url }}">({{ submission.group.acronym|upper }})</a>{% endif %}
                {% if errors.group %}
                    <p class="mt-1 mb-0 text-danger">
                        <b>{{ errors.group }}</b> (Note: the Secretariat will be notified of this)
                    </p>
                {% endif %}
            </td>
        </tr>
        <tr>
            <th scope="row">File size</th>
            <td>{{ submission.file_size|filesizeformat }}</td>
        </tr>
        </tbody>
    </table>
    <h3 class="mt-5">Adjust meta-data</h3>
    {% if form_errors %}<div class="alert alert-danger my-3">Please fix the errors in the form below.</div>{% endif %}
    <form class="idsubmit" method="post">
        {% csrf_token %}
        {% bootstrap_form edit_form %}
        {% include "submit/submitter_form.html" %}
        {% include "submit/replaces_form.html" %}
        {% for form in author_forms %}
            <div {% if forloop.last %}id="cloner"{% endif %}>
                <h3 class="mt-5">Author {{ forloop.counter }}</h3>
                {% bootstrap_form form %}
                <input type="hidden" name="authors-prefix" value="{{ form.prefix  }}">
            </div>
        {% endfor %}
        <button class="btn btn-primary"
               type="button"
               id="add-author">
               Add another author
        </button>
        <br>
        <button class="btn btn-primary mt-3"
               type="submit">
            Submit for manual posting
        </button>
    </form>
    {% include "submit/problem-reports-footer.html" %}
{% endblock %}
{% block js %}
    {{ all_forms|merge_media:'js' }}<script src="{% static "ietf/js/draft-submit.js" %}"></script>
{% endblock %}